<?php
// 兼容php5.3
//date_default_timezone_set('Etc/UTC');

require "PHPMailer.php";
require "SMTP.php";
 
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtp.163.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 465;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
// 设置使用ssl加密方式登录鉴权
$mail->SMTPSecure = 'ssl';
//Username to use for SMTP authentication
$mail->Username = "websinfo@163.com";
//Password to use for SMTP authentication
$mail->Password = "NFPUOCWSWQLUQJCN";
//Set who the message is to be sent from
$mail->setFrom('websinfo@163.com', 'admin');
//Set an alternative reply-to address
//$mail->addReplyTo('replyto@example.com', 'First Last2');
//Set who the message is to be sent to
$mail->addAddress('610652724@qq.com', '苏');
//$mail->addAddress('237596253@qq.com', 'ju');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';//标题
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>测试邮件页面标题</title>
            <!-- 设置缩放 -->
            <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
            <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        </head>
        <body>
            <h1>这是测试邮件标题</h1>
            <div>
            这是测试邮件内容<span style="color:red">这里字是红色字</span>
            </div>
        </body>
        </html>
';
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));//内容
$mail->msgHTML($html);//内容
//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body1·11111111111111111111111';
//Attach an image file
$mail->addAttachment('1.jpg','图片一.jpg');//附件
 
//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent! success";
}
